package leetcode.easy;

import leetcode.base.TreeNode;

import java.util.LinkedList;
import java.util.List;

/**
 * ClassName: $144_PreorderTraversal
 * Description:
 * date: 2021-11-18 22:44
 *
 * @author liyifan
 */
public class $144_PreorderTraversal {

    List<Integer> res = new LinkedList<>();

    public List<Integer> preorderTraversal(TreeNode root) {
        preorder(root);
        return res;
    }

    public void preorder(TreeNode root) {
        if (root == null)
            return;
        res.add(root.val);
        preorderTraversal(root.left);
        preorderTraversal(root.right);
    }
}
